/* 小说分享App - SCSS混合器 */

// 按钮样式混合器
@mixin button-base {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-sm) var(--spacing-md);
  border-radius: var(--border-radius);
  font-size: var(--font-size-md);
  font-weight: 500;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  user-select: none;

  &:disabled {
    opacity: 0.5;
    cursor: not-allowed;
  }
}

@mixin button-primary {
  @include button-base;
  background: var(--gradient-primary);
  color: white;

  &:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
  }

  &:active:not(:disabled) {
    transform: translateY(0);
  }
}

@mixin button-secondary {
  @include button-base;
  background-color: var(--background-light);
  color: var(--text-primary);
  border: 1px solid var(--border-color);

  &:hover:not(:disabled) {
    background-color: var(--background-medium);
  }
}

@mixin button-ghost {
  @include button-base;
  background-color: transparent;
  color: var(--primary-color);

  &:hover:not(:disabled) {
    background-color: rgba(255, 107, 53, 0.1);
  }
}

// 卡片样式混合器
@mixin card-base {
  background-color: var(--background-medium);
  border-radius: var(--border-radius);
  padding: var(--spacing-md);
  transition: all var(--transition-fast);
}

@mixin card-hover {
  &:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
  }
}

@mixin card-clickable {
  @include card-hover;
  cursor: pointer;
}

// 输入框样式混合器
@mixin input-base {
  width: 100%;
  padding: var(--spacing-sm) var(--spacing-md);
  background-color: var(--background-light);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  color: var(--text-primary);
  font-size: var(--font-size-md);
  transition: all var(--transition-fast);

  &::placeholder {
    color: var(--text-muted);
  }

  &:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(255, 107, 53, 0.2);
  }
}

// 文字截断混合器
@mixin text-truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@mixin text-truncate-lines($lines: 2) {
  display: -webkit-box;
  -webkit-line-clamp: $lines;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

// 渐变文字混合器
@mixin gradient-text {
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

// 加载状态混合器
@mixin loading-skeleton {
  background: linear-gradient(90deg, var(--background-light) 25%, var(--background-medium) 50%, var(--background-light) 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s infinite;
}

@keyframes skeleton-loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

// 淡入动画混合器
@mixin fade-in($duration: 0.3s) {
  animation: fadeIn $duration ease-in-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

// 滑入动画混合器
@mixin slide-in-up($duration: 0.3s, $distance: 20px) {
  animation: slideInUp $duration ease-out;
}

@keyframes slideInUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

// 响应式混合器
@mixin mobile {
  @media (max-width: 768px) {
    @content;
  }
}

@mixin tablet {
  @media (min-width: 769px) and (max-width: 1024px) {
    @content;
  }
}

@mixin desktop {
  @media (min-width: 1025px) {
    @content;
  }
}

// Flexbox 工具混合器
@mixin flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

@mixin flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

@mixin flex-column {
  display: flex;
  flex-direction: column;
}

// 绝对定位居中混合器
@mixin absolute-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

// 固定宽高比混合器
@mixin aspect-ratio($width, $height) {
  position: relative;

  &::before {
    content: '';
    display: block;
    padding-top: calc(#{$height} / #{$width} * 100%);
  }

  > * {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
  }
}

// 滚动条样式混合器
@mixin custom-scrollbar($width: 4px, $track-color: var(--background-light), $thumb-color: var(--text-muted)) {
  &::-webkit-scrollbar {
    width: $width;
  }

  &::-webkit-scrollbar-track {
    background: $track-color;
    border-radius: $width / 2;
  }

  &::-webkit-scrollbar-thumb {
    background: $thumb-color;
    border-radius: $width / 2;

    &:hover {
      background: darken($thumb-color, 10%);
    }
  }
}